<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
  <title>欢迎</title>
  <style>
    * {
      margin: 0;
      padding: 0;
      box-sizing: border-box;
      font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
    }

    body {
      background: linear-gradient(135deg, #fae18e 0%, #e4edf5 100%);
      min-height: 100vh;
      display: flex;
      justify-content: center;
      padding: 20px;
    }

    .container {
      width: 100%;
      max-width: 1200px;
    }

    /* 导航栏样式 */
    .navbar {
      background: rgba(255, 255, 255, 0.95);
      box-shadow: 0 5px 20px rgba(0, 0, 0, 0.08);
      border-radius: 15px;
      padding: 0 25px;
      display: flex;
      justify-content: space-between;
      align-items: center;
      height: 80px;
      margin-bottom: 40px;
      position: relative;
      z-index: 100;
    }

    .logo {
      display: flex;
      align-items: center;
    }

    .logo-icon {
      background: linear-gradient(135deg, #cb2711 0%, #fcca25 100%);
      width: 45px;
      height: 45px;
      border-radius: 12px;
      display: flex;
      align-items: center;
      justify-content: center;
      margin-right: 12px;
    }

    .logo-icon i {
      color: white;
      font-size: 22px;
    }

    .logo-text {
      font-size: 24px;
      font-weight: 700;
      color: #2c3e50;
      letter-spacing: -0.5px;
    }

    .logo-text span {
      color: #4a6cf7;
    }

    .nav-links {
      display: flex;
      list-style: none;
    }

    .nav-links li {
      margin: 0 15px;
      position: relative;
    }

    .nav-links a {
      text-decoration: none;
      color: #4a5568;
      font-size: 17px;
      font-weight: 500;
      padding: 8px 5px;
      transition: all 0.3s ease;
      position: relative;
    }

    .nav-links a:hover {
      color: #4a6cf7;
    }

    .nav-links a::after {
      content: '';
      position: absolute;
      bottom: 0;
      left: 0;
      width: 0;
      height: 3px;
      background: linear-gradient(90deg, #6a11cb, #2575fc);
      border-radius: 10px;
      transition: width 0.4s ease;
    }

    .nav-links a:hover::after {
      width: 100%;
    }

    .nav-buttons {
      display: flex;
      align-items: center;
    }

    .search-box {
      position: relative;
      margin-right: 20px;
    }

    .search-box input {
      padding: 10px 15px 10px 40px;
      border-radius: 30px;
      border: 1px solid #e2e8f0;
      background: #f8fafc;
      width: 200px;
      font-size: 15px;
      transition: all 0.3s ease;
    }

    .search-box input:focus {
      outline: none;
      border-color: #a3bffa;
      box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.2);
      width: 220px;
    }

    .search-icon {
      position: absolute;
      left: 15px;
      top: 50%;
      transform: translateY(-50%);
      color: #a0aec0;
    }

    .btn {
      padding: 10px 25px;
      border-radius: 30px;
      font-weight: 600;
      font-size: 15px;
      cursor: pointer;
      transition: all 0.3s ease;
      border: none;
    }

    .login-btn {
      background: transparent;
      color: #f7b24a;
      border: 2px solid #f7da4a;
      margin-right: 10px;
    }

    .login-btn:hover {
      background: #f7da4a;
      color: white;
      transform: translateY(-2px);
      box-shadow: 0 5px 15px rgb(243, 230, 168);
    }

    .register-btn {
      background: linear-gradient(135deg, #cb2111 0%, #fcbf25 100%);
      color: white;
    }

    .register-btn:hover {
      transform: translateY(-2px);
      box-shadow: 0 5px 15px rgb(245, 231, 167);
    }

    /* 移动设备适配 */
    @media (max-width: 992px) {
      .nav-links {
        display: none;
      }

      .navbar {
        padding: 0 20px;
      }

      .search-box input {
        width: 160px;
      }

      .search-box input:focus {
        width: 180px;
      }
    }

    @media (max-width: 768px) {
      .search-box {
        display: none;
      }

      .nav-buttons .btn {
        padding: 8px 15px;
        font-size: 14px;
      }

      .logo-text {
        font-size: 20px;
      }

      .logo-icon {
        width: 38px;
        height: 38px;
      }
    }

    /* 内容区域样式 */
    .content {
      background: white;
      border-radius: 15px;
      padding: 40px;
      box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
    }

    .content h1 {
      color: #2c3e50;
      margin-bottom: 20px;
      font-size: 32px;
    }

    .content p {
      color: #4a5568;
      line-height: 1.8;
      margin-bottom: 20px;
      font-size: 18px;
    }

    .publish-btn {
      display: inline-block;
      background: linear-gradient(135deg, #cb2111 0%, #fcbf25 100%);
      color: white;
      padding: 12px 25px;
      border-radius: 30px;
      font-weight: 600;
      font-size: 16px;
      cursor: pointer;
      transition: all 0.3s ease;
      border: none;
      text-decoration: none;
      margin-left: 20px;
      box-shadow: 0 4px 10px rgba(252, 191, 37, 0.3);
    }

    .publish-btn:hover {
      transform: translateY(-2px);
      box-shadow: 0 6px 15px rgba(252, 191, 37, 0.4);
    }

    .publish-btn i {
      margin-right: 8px;
    }

    .welcome-section {
      display: flex;
      align-items: center;
      margin-bottom: 30px;
      flex-wrap: wrap;
    }

    .welcome-text {
      flex: 1;
      min-width: 300px;
    }

    .section-title h2 {
      color: #2c3e50;
      font-size: 28px;
      margin-right: 15px;
    }

    .section-title .divider {
      flex: 1;
      height: 2px;
      background: linear-gradient(90deg, #f7b24a, #cb2111);
      border-radius: 2px;
    }

    .articles-container {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
      gap: 25px;
      margin-top: 10px;
    }

    .article-card {
      background: #fff;
      border-radius: 16px;
      overflow: hidden;
      box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
      transition: all 0.3s ease;
      display: flex;
      flex-direction: column;
      height: 150px;
      width: 350px;
    }

    .article-card:hover {
      transform: translateY(-8px);
      box-shadow: 0 12px 30px rgba(0, 0, 0, 0.15);
    }

    .card-header {
      position: relative;
      height: 160px;
      overflow: hidden;
    }

    .card-header img {
      width: 100%;
      height: 100%;
      object-fit: cover;
      transition: transform 0.5s ease;
    }

    .article-card:hover .card-header img {
      transform: scale(1.05);
    }

    .rank-badge {
      position: absolute;
      top: 15px;
      left: 15px;
      width: 36px;
      height: 36px;
      background: linear-gradient(135deg, #cb2111 0%, #fcbf25 100%);
      color: white;
      border-radius: 50%;
      display: flex;
      align-items: center;
      justify-content: center;
      font-weight: bold;
      font-size: 16px;
      box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    }

    .comments-count {
      position: absolute;
      bottom: 15px;
      right: 15px;
      background: rgba(255, 255, 255, 0.9);
      padding: 6px 12px;
      border-radius: 20px;
      display: flex;
      align-items: center;
      font-weight: 600;
      color: #2c3e50;
      box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    }

    .comments-count i {
      color: #b8dff1;
      margin-right: 6px;
    }

    .card-body {
      padding: 20px;
      flex: 1;
      display: flex;
      flex-direction: column;
    }

    .card-body h3 {
      color: #2c3e50;
      margin-bottom: 12px;
      font-size: 20px;
      line-height: 1.4;
      flex: 1;
    }

    .date-info i {
      margin-right: 5px;
      color: #f7b24a;
    }

    /* 响应式调整 */
    @media (max-width: 768px) {
      .articles-container {
        grid-template-columns: 1fr;
      }

      .section-title h2 {
        font-size: 24px;
      }

      .welcome-section {
        flex-direction: column;
        align-items: flex-start;
      }

      .publish-btn {
        margin-left: 0;
        margin-top: 15px;
      }
    }
  </style>
  <!-- 引入Font Awesome图标 -->
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
</head>
<body>
<div class="content">
  <div class="welcome-section">
    <div class="welcome-text">
      <h1>欢迎,${user.account}!</h1>
      <p>在这里，分享记录孙颖莎球员和王楚钦球员的成长与荣誉。</p>
    </div>
    <a href="addArticle" class="publish-btn">
      <i class="fas fa-plus"></i> 发布新文章
    </a>
  </div>
  <div class="container">
    <!-- 导航栏 -->
    <nav class="navbar">
      <div class="logo">
        <div class="logo-icon"></div>
        <div class="logo-text"> Sun&Hope </div>
      </div>

      <ul class="nav-links">
        <li><a href="welcome"><i class="fas fa-home"></i> 首页 </a></li>
        <li><a href="allArticle"><i class="fas fa-folder"></i> 所有博客 </a></li>
        <li><a href="getPics"><i class="fas fa-archive"></i> 夺冠时刻 </a></li>
        <li><a href="#"><i class="fas fa-user"></i> 精彩合集 </a></li>
      </ul>

      <div class="nav-buttons">
        <div class="search-box">
          <form action="${pageContext.request.contextPath}/searchArticle" method="get">
            <i class="fas fa-search search-icon"></i>
            <input type="text" name="keyword" placeholder="搜索文章...">
            <button type="submit" style="display: none;"></button>
          </form>
        </div>

        <button class="btn register-btn" onclick="window.location.href='backend'">后台管理</button>
        <button class="btn login-btn" onclick="window.location.href='out'">退出登录</button>
      </div>
    </nav>

    <div class="articles-container">
      <c:forEach items="${top6Articles}" var="article" varStatus="status">
        <div class="article-card" >
          <div class="card-header">
            <img src="${pageContext.request.contextPath}/image/pp.jpg">
            <div class="rank-badge">${status.index + 1}</div>
            <div class="comments-count">
              <i class="fas fa-comment"></i> ${article.commentCount}条评论
            </div>
          </div>
          <div class="card-body">
            <h3>
              <a href="articleDetail?id=${article.id}">${article.title}</a>
            </h3>
          </div>
        </div>
      </c:forEach>
    </div>
  </div>
</div>

<script>
  // 移动菜单切换功能
  document.querySelector('.mobile-menu-btn')?.addEventListener('click', function() {
    const navLinks = document.querySelector('.nav-links');
    if (navLinks.style.display === 'flex') {
      navLinks.style.display = 'none';
    } else {
      navLinks.style.display = 'flex';
      navLinks.style.flexDirection = 'column';
      navLinks.style.position = 'absolute';
      navLinks.style.top = '80px';
      navLinks.style.left = '0';
      navLinks.style.right = '0';
      navLinks.style.background = 'white';
      navLinks.style.padding = '20px';
      navLinks.style.boxShadow = '0 10px 20px rgba(0,0,0,0.1)';
      navLinks.style.borderBottomLeftRadius = '15px';
      navLinks.style.borderBottomRightRadius = '15px';

      navLinks.querySelectorAll('li').forEach(li => {
        li.style.margin = '10px 0';
      });
    }
  });

  // 搜索框聚焦效果
  const searchInput = document.querySelector('.search-box input');
  if (searchInput) {
    searchInput.addEventListener('focus', function() {
      this.parentElement.style.transform = 'scale(1.05)';
    });

    searchInput.addEventListener('blur', function() {
      this.parentElement.style.transform = 'scale(1)';
    });
  }

  // 卡片悬停效果增强
  const cards = document.querySelectorAll('.article-card');
  cards.forEach(card => {
    card.addEventListener('mouseenter', function() {
      this.style.zIndex = '10';
    });

    card.addEventListener('mouseleave', function() {
      this.style.zIndex = '1';
    });
  });
</script>
</body>
</html>